namespace ghost{
    export class NumberObj extends NoDepthObj
    {
        private _numberSp:GYSprite;
        private _numberLab:ImageLabel;
        constructor(sc:SceneManager)
        {
            super(sc);            
        }                
        public setName(name:string):void
        {
            let s= this;            
            s._numberLab.text = s._numberLab && name?name:"";
            if(!s._cfg.labelHeight)
                s._numberLab.y = -s._numberLab.textHeight >> 1;
            if(!s._cfg.labelWidth)
                s._numberLab.x = -s._numberLab.textWidth >> 1;
        }   
        protected resetingSts():void
		{			
			let s= this;			
			s.del();
		}			
        public getNameText():string
        {
            return this._numberLab?this._numberLab.text:"";
        }
        public setSkin(skinObj:any) :void
        {
            super.setSkin(skinObj); 
            let s= this;            
            if(s._numberLab == null)
            {                
                s._numberSp = new GYSprite;                
                s._numberLab = new ImageLabel;                     
                s._numberLab.align = "center";                    
                if(s._cfg.labelWidth)
                    s._numberLab.width = s._cfg.labelWidth;
                if(s._cfg.labelHeight)
                    s._numberLab.height = s._cfg.labelHeight;
                s._numberLab.x = -s._numberLab.width >> 1;
                s._numberLab.y = -s._numberLab.height >> 1;
                s._numberSp.addChild(s._numberLab);                
            }
            s.setNumSkin(SkinDictionary.getNumSkin(s._cfg.numSkin));            
            s._skin.addChild(s._numberSp);            
        }        
        public setNumSkin(data:ILabelData):void
        {
            this._numberLab.setData(data);  
        }
        public worldPosSet():void
		{            
			let s= this;
            let o:GameRole;
            o = s._owner?<GameRole>s._owner:s;
            if(s._layerType == map2D.LayerType.DEF)
            {
                s._skin.x = o.absX;
                s._skin.y = o.absY;
            }                      
			else
			{
                s._skin.x = o.absX - s._scene.mapX;
                s._skin.y = o.absY - s._scene.mapY - s._absZ;
			}            
            if(s._numberSp)
            {
                s._numberSp.alpha = s._skinPart.alpha;
                s._numberSp.scaleX = s._skinPart.getScaleX();
                s._numberSp.scaleY = s._skinPart.getScaleY();                
            }
        }
        public beforeToPool():void
        {
            let s = this;   
            if(s._owner)
                (<GameRole>s._owner).removeNumber(s);
            super.beforeToPool();                     
            if(s._numberLab)
                s._numberLab.text = "";
        }
        
    }
}